<?php

class UserController extends Controller_Action {
    
    public function indexAction() {
        $this->_redirect('/user/loginForm');
    }
    
    public function loginFormAction() {
        
    }
    
    public function loginAction() {
        $res = Application_Auth::getInstance()->authenticate($this->_request->login, $this->_request->password);
        $this->_redirect('/home');
    }
    
    public function registrationFormAction() {
        
    }
    
    public function saveAction() {
        try {
            $user            = Application_Auth::getInstance()->createUser($this->_request->login);
            $user->firstName = $this->_request->firstName;
            $user->lastName  = $this->_request->lastName;
            $user->email     = $this->_request->email;
            $user->password  = $this->_request->password;
        } catch (Application_Exception $e) {
            
        }
        $this->_forward('user', 'login', $this->_getAllParams());
        
    }
    
    public function logoutAction() {
        Application_Auth::getInstance()->logout();
        $this->_redirect('/home');
    }
    
}